﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FB.Utilities;

namespace FB.DataAccess
{
    public partial class Tag
    {
        public Tag() { }
        public Tag(Guid id, string name)
        {
            ID = id;
            Name = name;
        }
        public Tag(View_VideoTag view_VideoTag)
        {
            ID = view_VideoTag.IDTag;
            Name = view_VideoTag.TagName;
        }
    }

    public partial class VideoCategory
    {
        public VideoCategory() { }
        public VideoCategory(Guid id, string name, string desc)
        {
            ID = id;
            Name = name;
            Description = desc;
        }
        public VideoCategory(View_VideoInCategory view_VideoCate)
        {
            ID = view_VideoCate.CategoryID;
            Name = view_VideoCate.CatName;
            Description = view_VideoCate.CatDescription;
        }
    }

    public partial class Video
    {
        public Video()
        { }
        public Video(YouTubeVideoObject inData)
        {
            this.ID = Guid.NewGuid();
            this.Author = inData.Author;
            this.ChanelID = inData.ChanelID;
            Decimal DurationTemp;
            if(Decimal.TryParse(inData.Duration, out DurationTemp))
            {
                this.Duration = DurationTemp;
            }
            this.Title = inData.Title;
            this.Private = inData.Private;
            this.UTitle = inData.Title;
            this.UDescription = inData.Description;
            this.URatingAverage = (decimal)inData.RatingAverage;
            this.UViewCount = inData.ViewCount;
            this.YoutubeID = inData.VideoId;
            this.CreatedDate = DateTime.Now;
            this.LastCheckAliveDate = DateTime.Today;
            this.LastFeedDate = DateTime.Today;
            this.UTags = inData.GetTagsString();
            this.Enable = false;
            this.ThumbnailUrl = "http://i.ytimg.com/vi/" + inData.VideoId + "/mqdefault.jpg";
        }
        public Video(View_VideoInCategory m)
        {
            ID = m.ID;
            YoutubeID = m.YoutubeID;
            Title = m.Title;
            Duration = m.Duration;
            ThumbnailUrl = m.ThumbnailUrl;
            ChanelID = m.ChanelID;
            Author = m.Author;
            Private = m.Private;
            UTitle = m.UTitle;
            UDescription = m.UDescription;
            ULiked = m.ULiked;
            UDisliked = m.UDisliked;
            UViewCount = m.UViewCount;
            URatingAverage = m.URatingAverage;
            Description = m.Description;
            UTags = m.UTags;
            Liked = m.Liked;
            Disliked = m.Disliked;
            ViewCount = m.ViewCount;
            CreatedDate = m.CreatedDate;
            Enable = m.Enable;
            LastCheckAliveDate = m.LastCheckAliveDate;
            IsPlaylist = m.IsPlaylist;
            LastFeedDate = m.LastFeedDate;
        }

        public Video(View_VideoTag m)
        {
            ID = m.ID;
            YoutubeID = m.YoutubeID;
            Title = m.Title;
            Duration = m.Duration;
            ThumbnailUrl = m.ThumbnailUrl;
            ChanelID = m.ChanelID;
            Author = m.Author;
            Private = m.Private;
            UTitle = m.UTitle;
            UDescription = m.UDescription;
            ULiked = m.ULiked;
            UDisliked = m.UDisliked;
            UViewCount = m.UViewCount;
            URatingAverage = m.URatingAverage;
            Description = m.Description;
            UTags = m.UTags;
            Liked = m.Liked;
            Disliked = m.Disliked;
            ViewCount = m.ViewCount;
            CreatedDate = m.CreatedDate;
            Enable = m.Enable;
            LastCheckAliveDate = m.LastCheckAliveDate;
            IsPlaylist = m.IsPlaylist;
            LastFeedDate = m.LastFeedDate;
        }
    }
}
